#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
class MyStack {
public:
    queue<int> q1;
    queue<int> q2;
    MyStack() 
    {
        
    }

    void push(int x) {
        queue<int>& NoEmptyQueue = q1;
        queue<int>& EmptyQueue = q2;
        if (q1.empty())
        {
            swap(q1, q2);
        }
        NoEmptyQueue.push(x);
    }

    int pop() {
        queue<int>& NoEmptyQueue = q1;
        queue<int>& EmptyQueue = q2;
        if (q1.empty())
        {
            swap(q1, q2);
        }
        while (NoEmptyQueue.size() > 1)
        {
            int front = NoEmptyQueue.front();
            NoEmptyQueue.pop();
            EmptyQueue.push(front);
        }
        int front = NoEmptyQueue.front();
        NoEmptyQueue.pop();
        return front;
    }

    int top() {
        queue<int>& NoEmptyQueue = q1;
        queue<int>& EmptyQueue = q2;
        if (q1.empty())
        {
            swap(q1, q2);
        }
        return NoEmptyQueue.back();
    }

    bool empty() {
        return q1.empty() && q2.empty();
    }
};
class MyQueue {
public:
    stack<int> pushs;
    stack<int> pops;
    MyQueue() {

    }

    void push(int x) {
        pushs.push(x);
    }

    int pop() {
        if (!pops.empty())
        {
            int top = pops.top();
            pops.pop();
            return top;
        }
        else
        {
            while (!pushs.empty())
            {
                int top = pushs.top();
                pops.push(top);
                pushs.pop();
            }
            int top = pops.top();
            pops.pop();
            return top;
        }
    }

    int peek() {
        if (!pops.empty())
        {
            int top = pops.top();
            return top;
        }
        else
        {
            while (!pushs.empty())
            {
                int top = pushs.top();
                pops.push(top);
                pushs.pop();
            }
            int top = pops.top();
            return top;
        }
    }

    bool empty() {
        return pushs.empty() && pops.empty();
    }
};
class MyCircularQueue {
public:
    vector<int> v;
    int front;
    int rear;
    MyCircularQueue(int k) {
        v.resize(k + 1);
        front = 0;
        rear = 1;
    }

    bool enQueue(int value) {
        if (!isFull())
        {
            v[front++] = value;
            front %= v.size();
            rear++;
            rear %= v.size();
            return true;
        }
        else
        {
            return false;
        }
    }

    bool deQueue() {
        if (!isEmpty())
        {
            front++;
            front %= v.size();
            return true;
        }
        return false;
    }

    int Front() {
        return v[front];
    }

    int Rear() {
        return v[(rear - 1 + v.size()) % v.size()];
    }

    bool isEmpty() {
        return front == rear;
    }

    bool isFull() {
        return ((rear + 1)%v.size()) == front;
    }
};
int main()
{

    return 0;
}